package com.demoo.zjsu.controller.naxin;

import com.demoo.zjsu.dao.naxin.NaxinDAO;
import com.demoo.zjsu.model.naxin.DetailInfo;
import com.demoo.zjsu.model.userinfo.UserInfo;
import com.google.gson.Gson;
import com.mysql.jdbc.exceptions.MySQLDataException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;

/**
 * Created by jshjsh on 2016/9/3.
 */
@Controller
public class NaxinController {

    @RequestMapping("/naxin")
    public ModelAndView toNaxinPage() {
        return new ModelAndView("naxin/naxin");
    }

    @Autowired
    NaxinDAO dao;

    @ResponseBody
    @RequestMapping(value = "/naxin/login",method = RequestMethod.POST)
    public boolean login(@ModelAttribute("info") DetailInfo info) {
        if (dao.insertAllInfo(info)){
            return true;
        }
        return false;
    }

    @RequestMapping(value = "/naxin/{page}",method = RequestMethod.GET)
    public ModelAndView toNaxinContentPage(@PathVariable String page) {
        return new ModelAndView("naxin/"+page);
    }
}
